package com.ericpol.pageobject;

import static org.testng.Assert.fail;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;

public class POSeleniumBase {

	protected WebDriver driver;
	//private String baseUrl;
	private StringBuffer verificationErrors = new StringBuffer();

	public POSeleniumBase() {
		super();
	}

	@BeforeMethod
	public void setUp() throws Exception {
		openAndSetBrowser();
	}

	private void openAndSetBrowser() {
		driver = new FirefoxDriver();
//		baseUrl = base;
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	}

	@AfterMethod
	public void tearDown() throws Exception {
		quitBrowser();
	}

	private void quitBrowser() {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}
}